package top.jiangqiang.qyblog.core.mapstruct;

import org.mapstruct.*;
import org.springframework.core.convert.converter.Converter;
import top.jiangqiang.qyblog.core.constant.StorageTypeEnum;
import top.jiangqiang.qyblog.core.domain.entity.Storage;
import top.jiangqiang.qyblog.core.domain.vo.StorageVo;

/**
 * 存储器新增入参转换
 */
@Mapper(config = MapperSpringConfig.class, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface StorageToStorageVo extends Converter<Storage, StorageVo> {
    @Named(value = "convertType")
    default String convertType(StorageTypeEnum type) {
        return type.getType();
    }

    @Mappings({
            @Mapping(source = "type", target = "type", qualifiedByName = "convertType"),
    })
    @Override
    StorageVo convert(Storage source);
}

